package com.smart.car.common.res;

import com.smart.car.common.res.exception.BaseException;
import com.smart.car.common.res.exception.BusinessException;

/**
 * TODO 业务异常测试
 * @author zoutao.blog.csdn.net
 * @date 2021/5/12
 */
public class ExceptionTest {

    public static void main(String[] args) {
        String token = login("","95271");
        System.out.println(token);
    }

    static String login(String username, String password) {
        if (username.equals("admin")) {
            if (password.equals("9527")) {
                return "login successful";
            } else {
                throw new BusinessException("Error username or password.");
            }
        } else {
            throw new UserNotFoundException("User not found.");
        }
    }
}

//自定义业务异常01
class LoginFailedException extends BaseException {
    public LoginFailedException() {
        super();
    }
    public LoginFailedException(String message) {
        super(message);
    }
}
//自定义业务异常02
class UserNotFoundException extends BaseException {
    public UserNotFoundException() {
        super();
    }
    public UserNotFoundException(String message) {
        super(message);
    }
}
